#include <stdio.h>
#include <curses.h>
#include <unistd.h>

/**
  * purpose: bounce a message back and forth across the screen
  */

#define LEFTEDGE 	10
#define RIGHTEDGE 	30
#define ROW 		10

int main() {
	char* message = "Hello";
	char* blank = "     ";					// must cover the original message
	int dir = +1;
	int pos = LEFTEDGE;

	initscr();
	clear();

	while(1) {
		move(ROW, pos);
		addstr(message);					// draw string

		move(LINES - 1, COLS - 1);			// park the cursor
		refresh();
		sleep(1);

		move(ROW, pos);
		addstr(blank);						// cover the original message
		
		pos += dir;							// advance position
		if (pos >= RIGHTEDGE)				// check for bounce
			dir = -1;						// move from right to left
		if (pos <= LEFTEDGE)
			dir = +1;						// move from left to right
	}
}
